<?php
/* @var $this MenuItemsController */
/* @var $model MenuItems */
/* @var $form CActiveForm */
$this->widget('application.components.widgets.EFancyBox', array('target'=>'a.fancybox'));
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'menu-items-form',
	'enableAjaxValidation'=>false,
)); ?>
	<p class="note">Поля с <span class="required">*</span> должны быть заполнены.</p>

	<?php echo $form->errorSummary($model); ?>
	<div class="tabs">
		<a href="#tab_<?php echo Yii::app()->params->language; ?>" class="tab active"><?php echo Yii::app()->params->language; ?></a>
		<?php foreach(Yii::app()->params->languages as $key => $value): ?>
			<a href="#tab_<?php echo $key; ?>" class="tab"><?php echo $key; ?></a>
		<?php endforeach;?>
	</div>
	<div id="tab_<?php echo Yii::app()->params->language; ?>" class="screen visible">
		<div class="row">
			<?php echo $form->labelEx($model,'name'); ?>
			<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
			<?php echo $form->error($model,'name'); ?>
		</div>
	
		<div class="row">
			<?php echo $form->labelEx($model,'parent_id'); ?>
			<?php echo $form->dropDownList($model,'parent_id',CSelect::items('MenuItems'),  array('empty' => ('Выберите родителя'))); ?>
			<?php echo $form->error($model,'parent_id'); ?>
		</div>
		
		<div class="row">
			<?php echo $form->labelEx($model,'menu_id'); ?>
			<?php echo $form->dropDownList($model,'menu_id',CSelect::items('Menu'),  array('empty' => ('Выберите меню'))); ?>
			<?php echo $form->error($model,'menu_id'); ?>
		</div>
		
		<div class="row">
			<?php echo $form->labelEx($model,'url'); ?>
			<?php echo $form->textField($model,'url'); ?>
			<?php echo $form->error($model,'url'); ?>
			<a class="various fancybox.ajax" rel="group" href="<?php echo Yii::app()->createUrl('MenuItems/struct'); ?>">URL</a>
		</div>
	
		<div class="row">
			<?php echo $form->labelEx($model,'disabled'); ?>
			<?php 
				echo $form->dropDownList($model, 'disabled',
				array(
					'0' => 'Опубликован',
					'1' => 'Не опубликован', 
				)); 
			?>
			<?php echo $form->error($model,'disabled'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'sort'); ?>
			<?php echo $form->textField($model,'sort'); ?>
			<?php echo $form->error($model,'sort'); ?>
		</div>
	</div>
	<?php 
	$lns = Yii::app()->params->languages; 
	$names = isset($model->lns) ? CHtml::listData($model->lns, 'ln', 'name') : array();
	foreach($lns as $key => $value) : 
	?>
	<div id="tab_<?php echo $key; ?>" class="screen">
			<div class="row">
				<?php echo $form->labelEx($model,'name'); ?>
				<?php echo $form->textField($model,'[lns]['.$key.']name',array('size'=>60,'maxlength'=>255, 'value'=> isset($names[$key]) ? $names[$key] : '' )); ?>
				<?php echo $form->error($model,'name'); ?>
			</div>
	</div>
	<?php endforeach;?>
<?php $this->endWidget(); ?>

</div><!-- form -->